package com.wondersgroup.fjzlpt.tbxt.controller.rest.wsj;

import com.alibaba.fastjson.JSONObject;
import com.quick.framework.boot.web.utils.RequestUtils;
import com.quick.framework.util.QuickPrincipalUtils;
import com.wondersgroup.fjzlpt.tbxt.beans.req.wsjRest.CheckBbReqBean;
import com.wondersgroup.fjzlpt.tbxt.beans.req.wsjRest.QueryNbByPageReqBean;
import com.wondersgroup.fjzlpt.tbxt.beans.req.wsjRest.QueryYbByPageReqBean;
import com.wondersgroup.fjzlpt.tbxt.beans.resp.BaseRespBean;
import com.wondersgroup.fjzlpt.tbxt.beans.resp.wsjRest.QueryNbByPageRespBean;
import com.wondersgroup.fjzlpt.tbxt.beans.resp.wsjRest.QueryShjlByPageRespBean;
import com.wondersgroup.fjzlpt.tbxt.beans.resp.wsjRest.QueryYbByPageRespBean;
import com.wondersgroup.fjzlpt.tbxt.service.inter.wsj.WsjService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 卫生局业务服务类
 * Created by sanma on 2017/7/18.
 */
@RestController
@RequestMapping("/wsj")
@Api(value = "卫生局业务标准接口", tags = "WsjRestController", description = "卫生局业务API")
public class WsjRestController {

    @Autowired
    private WsjService wsjService;

    /**
     * 分页查询年报
     *
     * @param request
     * @return
     */
    @ApiOperation(value = "分页查询年报", notes = "分页查询年报-审核", response = QueryNbByPageRespBean.class)
    @RequestMapping(value = "/queryNbByPage", method = RequestMethod.POST)
    public JSONObject queryNbByPage(HttpServletRequest request, QueryNbByPageReqBean queryNbByPageReqBean) {
        Map<String, String> map = RequestUtils.GetParameterMap(request);
        map.put("XZQH", QuickPrincipalUtils.getXzqhdm(request));
        map.put("PTJGID", QuickPrincipalUtils.getPtjgID(request));
        return wsjService.queryNbByPage(map);
    }

    /**
     * 分页查询月报
     *
     * @param request
     * @return
     */
    @ApiOperation(value = "分页查询月报", notes = "分页查询月报-审核",response = QueryYbByPageRespBean.class)
    @RequestMapping(value = "/queryYbByPage", method = RequestMethod.POST)
    public JSONObject queryYbByPage(HttpServletRequest request, QueryYbByPageReqBean queryYbByPageReqBean) {
        Map<String, String> map = RequestUtils.GetParameterMap(request);
        map.put("XZQH", QuickPrincipalUtils.getXzqhdm(request));
        map.put("PTJGID", QuickPrincipalUtils.getPtjgID(request));
        return wsjService.queryYbByPage(map);
    }


    /**
     * 审核报表
     *
     * @param request
     * @return
     */
    @ApiOperation(value = "审核报表", notes = "审核报表(年报/月报)", response = BaseRespBean.class)
    @RequestMapping(value = "/checkBb", method = RequestMethod.POST)
    public JSONObject checkBb(HttpServletRequest request, CheckBbReqBean checkBbReqBean) {
        Map<String, String> map = RequestUtils.GetParameterMap(request);
        map.put("JGID",QuickPrincipalUtils.getYljgdm(request));
        map.put("JGMC",QuickPrincipalUtils.getYljgmc(request));
        return wsjService.checkBb(map);
    }

    /**
     * 分页查询审核记录
     *
     * @param request
     * @return
     */
    @ApiImplicitParam(name="BBID", value="报表ID",paramType = "query")
    @ApiOperation(value = "分页查询审核记录", notes = "分页查询某个报表审核记录",response = QueryShjlByPageRespBean.class)
    @RequestMapping(value = "/queryShjlByPage", method = RequestMethod.POST)
    public JSONObject queryShjlByPage(HttpServletRequest request) {
        Map<String, String> map = RequestUtils.GetParameterMap(request);
        return wsjService.queryShjlByPage(map);
    }


}
